<?php
namespace Goatherd\Content\Engine\Reader\Buffer;

use Goatherd\Content\Engine\Reader\IBufferedReader;

use Goatherd\Content\Engine\Queue\IItem;

use Goatherd\Content\Engine\Resource\IResource;

/**
 * IBuffer is a (persistent) caching interface for resource readers.
 * Identifier type is abstract and can depend on reader implementation.
 *
 * @category ContentEngine
 * @package Goatherd\Content\Engine
 * @subpackage Reader
 */
interface IBuffer
{
    /**
     * Get/ set active reader.
     *
     * @param AbstractReader $reader     [=null]
     * @return AbstractReader            if argument is null
     */
    public function activeReader(IBufferedReader $reader = null);

    /**
     *
     * @param IItem $item
     * @return boolean
     */
    public function hasResource(IItem $item);

    /**
     *
     * @param IItem $item
     * @return ResourceContainer
     */
    public function getResource(IItem $item);

    /**
     *
     * @param IItem $item
     * @param ResourceContainer $data
     */
    public function setResource(IItem $item, IResource $data);
}